<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"/>
<meta charset="UTF-8">
<title>飞马云监控登录</title>

    {% include 'template/baseCss.volt' %}
<link href="/css/vendor/login.less" type="text/css" rel="stylesheet/less">
<script src="/js/less.min.js"></script>
</head>

<body>
<main>
    <script>
        if(self!=top){
            alert("您已经登录超时,请重新登录");
            window.parent.location.href="/user/login";
        }

    </script>
    <img class="page-bg-img" src="/images/login/login-bg.png">
    <!-- 登录框 -->
    <div class="content-wrap">
        <table cellpadding="2" cellspacing="0">
            <tr><td class="logo" valign="bottom"><img id="system-icon" onerror="/images/login/login-logo.png" src="/images/login/login-logo.png"></td></tr>
            <tr><td id="system-name" class="title">云 监 控 平 台</td></tr>
            <tr><td class="name"><input id="input-name" type="text" name="phone-number" autocomplete="off" placeholder="手机号"></td></tr>
            <tr><td class="error-message"><p id="error_phone_msg" style="margin-left: 15px; color: red;text-align: left;visibility: hidden;">&nbsp;</p></td></tr>
            <tr><td class="pwd"><input id="input-pwd" type="password" name="password" autocomplete="off" placeholder="密码"></td></tr>
            <tr><td class="error-message"><p id="error_password_msg" style="margin-left: 12px; color: red;text-align: left;visibility: hidden;">&nbsp;</p>&nbsp;</td></tr>
            <tr><td class="button"><input id="login-button" type="submit" onclick="clickLogin()" value="登   录"></td></tr>
        </table>
    </div>

    <table class="system-info">
        <tr>
            <td>
                <ul>
                    <li class="button" onclick="window.open('/nofly-check.html')"><img src="/images/login/login-indicate.png">禁飞区查询</li>
                    <li class="button" onclick="window.open('/firmware/loginFirmwareCenter')"><img src="/images/login/login-indicate.png">测试固件下载中心</li>
                    <li class="button"><img src="/images/login/login-indicate.png">系统帮助</li>
                    <li class="button" onclick="window.open('http://www.feimarobotics.com')"><img src="/images/login/login-indicate.png">联系我们</li>
                </ul>
            </td>
        </tr>
        <tr>
            <td class="copy-right">Shenzhen Feima Robotics Technology CO.LTD</td>
        </tr>
    </table>
</main>
</body>

{% include 'template/baseJs.volt' %}
<script src="/js/baidu-statistics.js"></script>
<script src="/js/vendor/login.js"></script>




<script>
    var isPhoneCheckRight = true;
    var isPasswordCheckRight = true;
    var phoneInput = $("#input-name");
    var passwordInput = $("#input-pwd");
    var errorPhoneMsg = $("#error_phone_msg");
    var errorPasswordMsg = $("#error_password_msg");
    var defaultIco = "/images/login/login-logo.png";
    var defaultTitle = "云监控平台";
    $(function (){
//        defaultIco = $("#system-icon").attr("src");
//        defaultTitle = $("#system-name").text();
    });

    function validtorPassword() {
        var password = passwordInput.val();
        if (password.length < 6) {
            errorPasswordMsg.text("密码长度小于6位");
            errorPasswordMsg.css("visibility", "visible");
            isPasswordCheckRight = false;
        } else {
            isPasswordCheckRight = true;
            errorPasswordMsg.css("visibility", "hidden");
        }
        return password;
    }
    function validatorPhone() {
        var phone = phoneInput.val();
        if (!validator.isMobilePhone(phone, 'zh-CN')) {
            errorPhoneMsg.text("电话号码格式不正确");
            errorPhoneMsg.css("visibility", "visible");
            isPhoneCheckRight = false;

        } else {
            isPhoneCheckRight = true;
            errorPhoneMsg.css("visibility", "hidden");
        }
        return phone;

    }
    function replaceIco() {
        var phone = phoneInput.val();
        $.post("/user/changeIco",{
            "phone": phone
        },function (result){
            if (result){
                var data = result.data;
                if (checkImg(data["system_logo_url"])){
                    $("#system-icon").attr("src", data["system_logo_url"]);
                }else{
                    $("#system-icon").attr("src", defaultIco);
                }
                if (data["system_title"]){
                    $("#system-name").text(data["system_title"]);
                }else{
                    $("#system-name").text(defaultTitle);
                }
            }
        });
    }

    //绑定change事件
    phoneInput.change(function () {
        validatorPhone();
        replaceIco();
    });

    passwordInput.change(function () {
        validtorPassword();
    });

    function clickLogin() {

        var phone = validatorPhone();
        var password = validtorPassword();
        if (isPhoneCheckRight && isPasswordCheckRight) {
            loadingView.show();

            $.post("/user/dologin", {
                "phone": phone,
                "password": password
            }, function (result) {
                loadingView.remove();
                if(result.status==0){
                    window.location.href="/index";
                }else{
                    FAlert(result.message);

                }

            });
        }

    }
    $(document).on("keyup", function (event) {
        if (event.keyCode == "13"){
            $("#login-button").click();
        }
    });


</script>

</html>






